<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>
        欢迎登录后台管理系统
    </title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="shortcut icon" href="/favicon.ico" type="image/x-icon" />
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="format-detection" content="telephone=no">
    <link rel="stylesheet" href="./css/x-admin.css" media="all">
    <script src="js/jquery.min.js" type="text/javascript"></script>
    <script type="text/javascript" src="js/index.js"></script>
    <script type="text/javascript" src="js/frame.js"></script>
    <script src="lib/layui/layui.js" charset="utf-8"></script>
    <script src="js/x-admin.js"></script>
</head>
<body>
<div class="layui-layout layui-layout-admin">
    <div class="layui-header header header-demo">
        <div class="layui-main">
            <a class="logo" href="./index.html">
                后台管理系统
            </a>
            <ul class="layui-nav" lay-filter="">
                <li class="layui-nav-item"><img src="./images/logo.png" class="layui-circle" style="border: 2px solid #A9B7B7;" width="35px" alt=""></li>
                <li class="layui-nav-item">
                    <a href="javascript:;" id="username"></a>
                    <dl class="layui-nav-child"> <!-- 二级菜单 -->
                        <dd><a href="index.html">个人信息</a></dd>
                        <!--<dd><a href="">切换帐号</a></dd>-->
                        <dd><a id="exit">退出</a></dd>
                    </dl>
                </li>
                <!-- <li class="layui-nav-item">
                  <a href="" title="消息">
                      <i class="layui-icon" style="top: 1px;">&#xe63a;</i>
                  </a>
                  </li>
                <li class="layui-nav-item x-index"><a href="/">前台首页</a></li>-->
            </ul>
        </div>
    </div>
    <div class="layui-side layui-bg-black x-side">
        <div class="layui-side-scroll">
            <ul class="layui-nav layui-nav-tree site-demo-nav" lay-filter="side" id="t_menu">
                <!--<li class="layui-nav-item"><a class="javascript:;" href="javascript:;"><i class="layui-icon" style="top: 3px;">&#xe613;</i><cite>系统管理</cite></a>-->
                    <!--<dl class="layui-nav-child">-->
                        <!--<dd class="">-->
                            <!--<a href="javascript:;" _href="./modules/user/user-list.html">-->
                                <!--<cite>用户列表</cite>-->
                            <!--</a>-->
                        <!--</dd>-->
                        <!--<dd class="">-->
                            <!--<a href="javascript:;" _href="./modules/role/role-list.html">-->
                                <!--<cite>角色管理</cite>-->
                            <!--</a>-->
                        <!--</dd>-->
                        <!--<dd class="">-->
                            <!--<a href="javascript:;" _href="./admin-cate.html">-->
                                <!--<cite>权限分类</cite>-->
                            <!--</a>-->
                        <!--</dd>-->
                        <!--<dd class="">-->
                            <!--<a href="javascript:;" _href="./admin-rule.html">-->
                                <!--<cite>权限管理</cite>-->
                            <!--</a>-->
                        <!--</dd>-->
                    <!--</dl>-->
                <!--</li>-->
            </ul>
        </div>

    </div>
    <div class="layui-tab layui-tab-card site-demo-title x-main" lay-filter="x-tab" lay-allowclose="true">
        <div class="x-slide_left"></div>
        <ul class="layui-tab-title">
            <li class="layui-this">
                我的桌面
                <i class="layui-icon layui-unselect layui-tab-close">ဆ</i>
            </li>
        </ul>
        <div class="layui-tab-content site-demo site-demo-body">
            <div class="layui-tab-item layui-show">
                <iframe frameborder="0" src="./modules/welcome.html" class="x-iframe"></iframe>
            </div>
        </div>
    </div>
    <div class="site-mobile-shade">
    </div>
</div>
<script>
    $(function() {
        //获取当前登录用户信息
        var user;
        $.ajax({
            url: getContextPath() + "/html/getCurrentUser",
            type: "post",
            data: "",
            async:false,
            success: function (data) {
                if (data.success != false) {
                    user = data.content;
                    if (user == null) {
                        window.location.href = getRootPath();
                    }
                }
            },
            error: function (e) {
                alert("系统错误，请联系管理员！！");
            }
        });
        //获取当前菜单
        $.ajax({
            url: getContextPath() + "/html/getMenulistByRoleId",
            type: "post",
            data: {roleId:user.roleId},
            async:false,
            success: function (data) {
                if (data.success != false) {
                    var menuList = data.content;
                    createHtml(menuList);
                }
            },
            error: function (e) {
                alert("系统错误，请联系管理员！！");
            }
        });
    });

    function createHtml(data){
        var s ="";
        if(data!=null||data!=undefined){
            for(var i=0;i<data.length;i++){
                s +="<li class=\"layui-nav-item\"><a class=\"javascript:;\" href=\"javascript:;\"><i class=\"layui-icon\" style=\"top: 3px;\">&#xe613;</i><cite>"+data[i].menuName+"</cite></a>";
                if(data[i].childMenuList!=null||data[i].childMenuList!=undefined){
                    for(var a=0;a<data[i].childMenuList.length;a++){
                        var o = data[i].childMenuList[a];
                        s += '<dl class="layui-nav-child">'
                        s += '<dd class="">';
                        s += '<a href="javascript:;" _href="'+o.menuUrl+'">';
                        s += '<cite>'+o.menuName+'</cite>';
                        s += '</a>';
                        s += '</dd>';
                        s += '</dl>';
                    }
                }
                s += '</li>';
            }
            if(data.length>0){
                $("#t_menu").html(s);
            }
        }
    }

</script>
</body>
</html>